package cn.rkylin.oms.base.refundReasonType.dao;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import cn.rkylin.core.IDataBaseFactory;
import cn.rkylin.oms.base.refundReasonType.domain.EcRefundReason;
import cn.rkylin.oms.base.refundReasonType.domain.RdfundReasonRelation;
import cn.rkylin.oms.base.refundReasonType.domain.RdfundReasonType;
import cn.rkylin.oms.base.refundReasonType.vo.RdfundReasonTypeVO;


/**
 * 退款原因类型访问层
 * 
 * @author qitao
 * @version 1.0
 * @created 17-7月-2017
 */
@Repository(value = "rdfundReasonTypeDAO")
public class RdfundReasonTypeDAOImpl implements IRdfundReasonTypeDAO {

    @Autowired
    protected IDataBaseFactory dao;

    /**
     * 查询退款原因类型根据退款原因编码
     * 
     * @param params 数据参数
     */
    public int getRdfundReasonTypeCountByCode(Map<String, Object> params) throws Exception {
        List<RdfundReasonType> list = dao.findList("getRdfundReasonTypeCountByCode", params);
        if (list.size() > 0) {
            return 1;
        } else {
            return 0;
        }
    }

    /**
     * 插入退款原因类型
     * 
     * @param params 数据参数
     */
    public int insertRdfundReasonType(Map<String, Object> params) throws Exception {
        return dao.insert("insertRdfundReasonType", params);
    }

    /**
     * 查询退款原因类型
     * 
     * @param params 数据参数
     */
    public RdfundReasonType getRdfundReasonTypeInfo(Map<String, Object> params) throws Exception {
        List<RdfundReasonTypeVO> list = dao.findList("getRdfundReasonTypeInfo", params);

        if (list != null && list.size() > 0) {
            return list.get(0);
        }

        return null;
    }

    /**
     * 修改退款原因类型
     * 
     * @param params 数据参数
     */
    public int updateRdfundReasonType(Map<String, Object> params) throws Exception {
        return dao.update("updateRdfundReasonType", params);
    }

    /**
     * 删除平台退款原因关联为退款原因类型
     * 
     * @param params 数据参数
     */
    public int deleteRdfundReasonRelationForType(Map<String, Object> params) throws Exception {
        return dao.update("deleteRdfundReasonRelationForType", params);
    }

    /**
     * 删除退款原因类型
     * 
     * @param params 数据参数
     */
    public int deleteRdfundReasonType(Map<String, Object> params) throws Exception {
        return dao.update("deleteRdfundReasonType", params);
    }

    /**
     * 查询平台退款原因关联list
     * 
     * @param params 数据参数
     */
    public List<RdfundReasonRelation> getRdfundReasonRelationList(Map<String, Object> params) throws Exception {
        return dao.findList("getRdfundReasonRelationList", params);
    }
    
    /**
     * 删除平台退款原因关联
     * 
     * @param params 数据参数
     */
    public int deleteRdfundReasonRelation(Map<String, Object> params) throws Exception {
        return dao.update("deleteRdfundReasonRelation", params);
    }

    /**
     * 查询平台退款原因list
     * 
     * @param params 数据参数
     */
    public List<EcRefundReason> getEcRefundReasonList(Map<String, Object> params) throws Exception {
        return dao.findList("getEcRefundReasonList", params);
    }

    /**
     * 查询平台退款原因是否已经被匹配
     * 
     * @param params 数据参数
     */
    public int getRefundReasonRelationCountByCondition(Map<String, Object> params) throws Exception {
        List<RdfundReasonRelation> list = dao.findList("getRefundReasonRelationCountByCondition", params);
        if (list.size() > 0) {
            return 1;
        } else {
            return 0;
        }
    }

    /**
     * 插入平台退款原因关联
     * 
     * @param params 数据参数
     */
    public int insertRdfundReasonRelation(Map<String, Object> params) throws Exception {
        return dao.insert("insertRdfundReasonRelation", params);
    }

}
